from tw.api import WidgetsList,CSSLink,js_callback
from tw.forms import TableForm
from tg import url
from tw.jquery.flexigrid import FlexiGrid

colModel = [
    {'display':'ID', 'name':'record_id', 'width':20, 'align':'center'},
    {'display':'Title', 'name':'title', 'width':700, 'align':'left'},
#    {'display':'Description', 'name':'description', 'width':200, 'align':'left'},
]

searchitems = [
            {'display':'Title', 'name':'title', 'isdefault':True},
          ]

buttons=[
  {'name':'Add', 'bclass':'add', 'onpress': js_callback('/record/add_record')},
  {'name':'Delete', 'bclass':'delete', 'onpress': js_callback('/record/delete_record')},
  {'separator':True}
]

grid = FlexiGrid(id='flex', fetchURL='/record/fetch', title='Records',
            colModel=colModel, useRp=True, rp=20,
            sortname='title', sortorder='asc', usepager=True,
            searchitems=searchitems,
            showTableToggleButton=True,
            #buttons=buttons,
            width=700,
            height=400
)

